local skill = fk.CreateSkill{
    name = "bahuangsishiling_other&",
}

Fk:loadTranslationTable{
    ["bahuangsishiling_other&"] = "死士令",
    [":bahuangsishiling_other&"] = "每轮限一次，所有本轮明置过武将牌的晋势力角色可以移除其副将的武将牌并发动以下一个未以此法发动过的技能：“瞬覆”，“奉迎”，“将略”，“勇进”和“乱武”。",

    ["#bahuangsishiling-choose"] = "死士令：移除你的副将并发动一个未以此法发动的技能",
}

local H = require "packages.ol_hegemony.util"

skill:addEffect("active",{
    anim_type = "special",
    can_use = function (self, player)
       local targets = Fk:currentRoom().players
       return table.every(targets, function (p) return p:usedSkillTimes(skill.name, Player.HistoryRound) == 0 and p:usedSkillTimes(skill.name, Player.HistoryGame) < 6 end)
        and H.hasHegLordSkill(Fk:currentRoom(), player, "ld__jiaping") and player:getMark("GeneralRevealed-round") > 0
       and player.deputyGeneral ~= "blank_shibing" and player.deputyGeneral ~= "blank_nvshibing"
    end,
    target_num = 0,
    card_num = 0,
    on_use = function (self, room, effect)
        local player = effect.from
        local skill_list = { "jin_heg__shunfu","new_ld__fengying","ld__jianglue","yongjin","hs__luanwu" }
        local lord = table.filter(room.alive_players, function (p) return p:hasSkill("ld__jiaping") end)
        local skill_used = lord[1]:getTableMark("sishiling_used") or {}
        for _, s in ipairs(skill_used) do
            if table.contains(skill_list, s) then
            table.removeOne(skill_list, s)
          end
        end
        if #skill_list == 0 then return false end
        local result = room:askToCustomDialog(player,{
        skill_name = skill.name,
        qml_path = "packages/utility/qml/ChooseSkillBox.qml",
        extra_data = {
            table.slice(skill_list, 1, #skill_list + 1),
            0,
            1,
            "#bahuangsishiling-choose",
        }})
        if result == "" then return false end
        local choice = result
        room:addTableMarkIfNeed(lord[1], "sishiling_used", choice[1])
        if #choice > 0 then
            player:broadcastSkillInvoke(choice[1])
            room:doAnimate("InvokeUltSkill", {
              name = choice[1],
              player = H.getHegLord(room, player).id,
        })
            room:delay(400)
            H.removeGeneral(player, true)
            room:askToUseActiveSkill(player,{
                skill_name = choice[1],
                cancelable = false,
            })
        end
    end,
})

return skill